<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class backup extends MX_Controller
{
	function backup()
	{
		parent::__construct();
		$this->check_login();
	}

	function index()
	{
		$this->load->dbutil();
		$time = date('d-m-Y H-i-s', time());
		$backup =& $this->dbutil->backup();
		$this->load->helper('file');
		write_file('database/database_'.$time.'.gz', $backup);
		$this->load->helper('download');
		force_download('database_'.$time.'.gz', $backup);		
	}	
}